<?php

/**
 * This is the model class for table "products".
 *
 * The followings are the available columns in table 'products':
 * @property integer $id
 * @property string $name
 * @property integer $price
 * @property string $image
 * @property string $thumb
 * @property string $description
 * @property string $short_descript
 * @property integer $promote
 * @property string $created
 * @property string $updated
 * @property integer $category_id
 *
 * The followings are the available model relations:
 * @property Categories $category
 */
class Products extends ProductsBase
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Products the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'products';
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria	= new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('price',preg_replace('/\s/', '', $this->price), true);
		$criteria->compare('image',$this->image,true);
		$criteria->compare('thumb',$this->thumb,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('short_descript',$this->short_descript,true);
		$criteria->compare('promote',$this->promote);
		$criteria->compare('status',$this->status);
		$criteria->compare('created',$this->created,true);
		$criteria->compare('updated',$this->updated,true);
		$criteria->compare('category_id',$this->category_id, true);
		$criteria->compare('code',$this->code,true);
		$criteria->addCondition('id != \'0\'');

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}